package com.atguigu.map;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * @program: IDEAcode
 * @description:
 * @author: Mr.zjx
 * create: 2021-08-03-22-57
 **/
public class TestPerson {
    public static void main(String[] args) {
        hashMap();
    }
    private static void hashMap(){
        Map<Person,String> map = new TreeMap<Person,String>();
        //new出的不是同一个对象，需要重写equels方法
        map.put(new Person("a",16), "深圳");
        map.put(new Person("a",16), "深圳");
        map.put(new Person("b",23), "北京");
        map.put(new Person("c",19), "上海");
        map.put(new Person("d",11), "东莞");
        for (Person key : map.keySet()){
            System.out.println(key+"="+map.get(key));
        }
    }
}
